#!/bin/bash
read -t 30  -p "请输入服务器地址：" ipaddr
read -t 30  -p "请输入服务器用户：" username
read -t 30  -p "请输入服务器端口：" port

path=$(dirname $(pwd))\/
# touch "$path"ssh_login_x.desktop
# touch "$path"ssh_config.sh
# echo $path
echo "#!/bin/bash

ipaddr=$ipaddr
username=$username
port=$port

read -t 30 -s -p \"请输入服务器密码：
\" passwod

# 使用sshpass自动输入密码进行登录
sshpass -p "\$passwod" ssh -o StrictHostKeyChecking=no -p \$port \$username@\$ipaddr
" > "$path".ssh_config.sh

echo "[Desktop Entry]
Name=service
Comment=连接SSH服务器
Exec=gnome-terminal -- /usr/share/applications/.ssh_config.sh
Icon=/usr/share/applications/sshpng.png
Terminal=true
Type=Application
StartupNotify=true
Categories=Utility;" > "$path"ssh_login_x.desktop
echo "接下来需要输入您本地的管理员密码  (无需请忽略)"
chmod  u+x "$path"ssh_login_x.desktop
chmod  +x "$path".ssh_config.sh

sudo cp ./sshpng.png /usr/share/applications/
sudo mv "$path".ssh_config.sh  /usr/share/applications/

sudo apt-get update
sudo apt-get install sshpass



exit

